﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 七天入手上位机第一个项目
{
    public partial class StationState : UserControl
    {
        public StationState()
        {
            InitializeComponent();
        }

        private string deviceNum = "D01";
        [Browsable(true)]
        [Description("设置或获取设备的编号")]
        public string DeviceNum
        {
            get { return deviceNum; }
            set
            {
                deviceNum = value;
                this.lbl_deviceNum.Text = value;
            }
        }

        private string deviceName = "名称";
        [Browsable(true)]
        [Description("设置或获取设备的名称")]
        public string DeviceName
        {
            get { return deviceName; }
            set
            {
                deviceName = value;
                this.gp_panel.Title = value;
            }
        }

        private int state = 1;
        [Browsable(true)]
        [Description("设置或获取设备的状态")]
        public int State
        {
            get { return state; }
            set
            {
                state = value;
                switch (state)
                {
                    //运行
                    case 1:
                        this.lbl_State.Text = "运行";
                        this.pic_light.Image = Properties.Resources.运行;
                        lbl_num.ForeColor = Color.Green;
                        lbl_deviceNum.ForeColor = Color.Green;
                        break;
                    //报警
                    case 2:
                        this.lbl_State.Text = "报警";
                        this.pic_light.Image = Properties.Resources.故障;
                        lbl_num.ForeColor = Color.Red;
                        lbl_deviceNum.ForeColor = Color.Red;
                        break;
                    //未启用
                    case 3:
                        this.lbl_State.Text = "未启用";
                        this.pic_light.Image = Properties.Resources.关机;
                        lbl_num.ForeColor = Color.Gray;
                        lbl_deviceNum.ForeColor = Color.Gray;
                        break;
                }
            }
        }
    }
}
